Dynomotion

Group: DynoMotion Message: 8764 From: eric_kato_sanders Date: 12/2/2013
Subject: Execute and Wait lockup
Hi Tom,
I'm having a problem with the program locking up.  I figured out what is causing it, but don't know the proper way to solve it.
My spindleOnCW.c file does three things, it first checks my switch probe bit to see if it is not active ,(not active means it is plugged in).  If this is the case, then I use the MsgBox command to bring up the window warning as such and the spindle is not turned on.
If the probe is not hooked up, I set my pwm output to enabled.  I then delay a set number of seconds based upon the spindle speed before exiting the code.  This allows the spindle to get up to speed before any motion occurs.
I have at the end of my file:

double nowTime = Time_sec();
while((Time_sec() - nowTime) < delayTime)
{
         WaitNextTimeSlice();
}


In KMotionCNC, I have to setup for my M3 definition as Execute and Wait.  (Simply using Execute doesn't appear to create the delay I want).  This seems to work well, however if my probe is plugged in we get into a race condition and the GCodeInterpreter gets stuck in a loop waiting for a non "0" response from a WriteLineReadLine("CheckThread command.
So on one hand, the .c file is in a loop waiting on a signal from KMotionCNC that the MsgBox command has finished, and the GCodeInterpreter is also in a loop waiting for the thread to finish.  The GCodeInterpreter loop is preventing the KMotionCNC code from responding to the message to bring up the MessageBox. 
Any insight on how to handle this better?
Eric
Group: DynoMotion Message: 8766 From: Tom Kerekes Date: 12/2/2013
Subject: Re: Execute and Wait lockup
Hi Eric,

What Version are you using?  Try the latest test Version 4.31o.

Regards
TK

Group: DynoMotion Message: 8767 From: eric_kato_sanders Date: 12/2/2013
Subject: Re: Execute and Wait lockup

That's the version I'm using.

You can replicate this by using a file with nothing more than a MsgBox command, and running it from the user buttons as Execute and Wait.

It appears that with the tight loop in the dll, that Windows can't service the message pump so the timer in KMotionCNC isn't firing.  I was thinking of changing the timer into a thread.  A Sleep(0) command in the dll will allow the operating system to service the thread.

Eric




---In DynoMotion@yahoogroups.com, <tk@...> wrote:

Hi Eric,

What Version are you using?  Try the latest test Version 4.31o.

Regards
TK

Group: DynoMotion Message: 8768 From: Tom Kerekes Date: 12/2/2013
Subject: Re: Execute and Wait lockup
Hi Eric,

Yes I see there is a problem with a GUI button calling it with wait but not M3.  M3 normally runs from the Interpreter's worker Thread so it isn't a problem.

I don't think a worker thread would be a good idea because windows only lets the main thread do things to the GUI.  I don't think a Sleep(0) would make any difference either.  That would just time slice sooner.

One workaround is to write the KFLOP Program to just request the message but not wait for the response.  That seems to be what you need as I think you just intend to notify the Operator something bad happened.

Try the attached example.

Regards
TK

Group: DynoMotion Message: 8769 From: eric_kato_sanders Date: 12/3/2013
Subject: Re: Execute and Wait lockup

Thanks again  Tom,
Last night I looked long and hard at converting it from a timer based to thread based, but didn't want to deal with having to create custom messages to trigger some of the gui items I had added from the thread, (that particular .c file also has DoPC calls that send some custom messages back to KMotionCNC to depress a custom Spindle On button for instance).  Plus I wasn't 100% sure how much difference it would have made.  Timers are just so much easier to deal with.
I added MsgBoxNoWait and DoPCNoWait function to use for these kind of Exec/Wait instances and it seems to work pretty well

All that is left is to debug my probing routines and I'll be cutting my first part with the KFlop.  Attached are a couple of screen shots of the final main screen.  I have a 1024x1280 touch screen for my mill so I wanted buttons to be large enough to be "touchable"

  @@attachment@@
Group: DynoMotion Message: 8770 From: Tom Kerekes Date: 12/3/2013
Subject: Re: Execute and Wait lockup [2 Attachments]
Very cool Eric
Regards
TK